<%@ page import="by.home.Parameters" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="by.home.ChatRoom" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title></title>
</head>
<body>

<%
  Parameters parameters = (Parameters) request.getAttribute("params");
  ArrayList<ChatRoom> chatRooms = parameters.getChatRooms();

  for (ChatRoom chatRoom : chatRooms) {
%>
<form action="show_room.ctrl" method="post" id="chatRoomForm<%= chatRoom.getId()%>">
  <div style="border: 1px solid grey; width: 200px; margin-left: 20px; margin-top: 10px; padding: 5px; display: block;"
       onclick="document.getElementById('chatRoomForm<%= chatRoom.getId()%>').submit()">
    id: <%= chatRoom.getId()%> <br>
    header: <%= chatRoom.getHeader()%> <br>
    date: <%= chatRoom.getDate()%> <br>
    <input type="hidden" name="id" value="<%= chatRoom.getId()%>">
  </div>
</form>
<%
  }
%>
<br>

<form action="create_chat_room.ctrl" method="post">
  Chat room title: <input type="text" name="title"><br>
  <input type="submit" value="Submit"/>
</form>
</body>
</html>